package com.chookss.home.interview;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chookss.R;
import com.chookss.base.BaseViewHolderEx;
import com.chookss.home.entity.InterviewRecordsEntity;
import com.chookss.tools.ClearMoreZeroUtil;
import com.chookss.tools.Utils;

import java.util.List;

public class MyInterviewRecordsAdapter extends BaseQuickAdapter<InterviewRecordsEntity, BaseViewHolderEx> {
    private Context context;
    private int type;

    public MyInterviewRecordsAdapter(int layoutResId, Context context, @io.reactivex.annotations.Nullable List<InterviewRecordsEntity> data,int type) {
        super(layoutResId, data);
        this.context = context;
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolderEx helper, InterviewRecordsEntity item) {

        TextView tvName = helper.getView(R.id.tvName);
        TextView tvPhone = helper.getView(R.id.tvPhone);
        TextView tvScore = helper.getView(R.id.tvScore);
        TextView tvScoreAll = helper.getView(R.id.tvScoreAll);
        TextView tvTitle = helper.getView(R.id.tvTitle);
        TextView tvTime = helper.getView(R.id.tvTime);
        ImageView ivType = helper.getView(R.id.ivType);
        tvName.setText(item.getEmployeeName());
        tvPhone.setText("·"+item.getPhone());
        tvScore.setText(ClearMoreZeroUtil.subZeroAndDot(item.getScore()));
        tvScoreAll.setText("/"+ClearMoreZeroUtil.subZeroAndDot(item.getExamTotalScore())+"分");
        tvTitle.setText(item.getExamName());
        tvTime.setText(item.getCreateTime());
        if(type==2){
            ivType.setVisibility(View.VISIBLE);
            //pass1通过0未通过 空待评价
            //dayCount 1超过24小时0未超时 24小时
            if(Utils.isNull(item.getPass())){
                if("1".equals(item.getDayCount())){
                    ivType.setBackgroundResource(R.drawable.icon_timeout_30);
                }else{
                    ivType.setBackgroundResource(R.drawable.icon_no_pj_30);
                }
            }else {
                if("1".equals(item.getPass())){
                    ivType.setBackgroundResource(R.drawable.iv_pass_30);
                }else{
                    ivType.setBackgroundResource(R.drawable.iv_no_pass_30);
                }
            }
        }else{
            ivType.setVisibility(View.GONE);
        }
        helper.getItemView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent=new Intent(context, WebCommonActivity.class);
//                String url= NavigationTools.getAllUrl(context, Urls.indexAnswer);
//                String companyCode=new ShareUtils().getString(context, StaticClass.COMPANYCODE,"");
//                url=url+"&examCode="+item.getExamCode()+"&companyCode="+companyCode+"&personCode="+item.getEmployeeCode()+"&createTime="+Utils.getAccurateDate2(item.getCreateTime(),0,10)+"&recordUid="+item.getRecordUid()+"&totalNum="+ClearMoreZeroUtil.subZeroAndDot(item.getExamTotalNum());
//                intent.putExtra("url", url);
//                intent.putExtra("title",item.getExamName());
//                intent.putExtra("waterMark","16");
                if (item == null) {
                    return;
                }
                Intent intent=new Intent(context, InterviewExamResultActivity.class);
                intent.putExtra("type",type);
                intent.putExtra("interviewResult",item);
                context.startActivity(intent);
            }
        });
    }
}
